export function createDom(
  tagName: string,
  contentList,
  attr: { [key: string]: string | number | boolean },
  show = true,
) {
  const tag = document.createElement(tagName)
  for (let i = 0; i < contentList.length; i++) {
    const h = contentList[i]
    if (typeof h === 'string') {
      tag.innerHTML += h
    } else {
      tag.appendChild(h)
    }
  }
  for (const key in attr) {
    tag.setAttribute(key, attr[key])
  }
  show && document.body.appendChild(tag)
  return tag
}

export function createTitle(text) {
  const p = createDom('h6', [`---------------${text}-----------------------`], {}, false)
  createDom('div', [p], { class: 'item' })
}
